# Abstract class SearchEngine
class SearchEngine(object):
    def __getitem__(self, key):
        raise NotImplementedError, ''
    
    def __len__(self):
        raise NotImplementedError, ''
    
# List of installed searchengine api's
INSTALLED_SE = ['bing', 'google', 'yahoo']

# Function that uses all installed searchengines to get the results for searching query
def metasearch(query):
    engines = []
    
    # Import all search engines
    for se in INSTALLED_SE:
        exec "from %s import *" % se
    
    # Create all search engines
    for se in SearchEngine.__subclasses__():
        try:
            engines.append(se(query))
        except Exception:
            pass
    
    return engines